package com.sx.gongzhong.pest;

import com.sx.gongzhong.model.PublicBean;
import com.sx.gongzhong.model.ReplyUserBean;
import com.sx.gongzhong.net.ApiManager;
import com.sx.gongzhong.net.BaseCallBack;
import com.sx.gongzhong.view.IPublicView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by XZY on 2018/1/9.
 * 获取公共的字典列表
 */

public class PublicPest  {

    private IPublicView publicView;

    public PublicPest(IPublicView publicView) {
        this.publicView = publicView;
    }

    /**
     *
     * @param parentCode 父级字典项Code 现在固定
     */
    public void getPublicList(String parentCode){
        Map<String,Object> map= new HashMap<>();
        map.put("parentCode",parentCode);
        new ApiManager().getPublicList(map, new BaseCallBack<ReplyUserBean.BaseResult<List<PublicBean>>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<List<PublicBean>> response) {
                publicView.getPublicList(response.getData());
            }

            @Override
            public void onFailures(String message) {
                publicView.showError(message);
            }
        });

    }
}
